package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.form.SupplierForm;
import com.yxinsur.imc.business.form.SupplierListForm;
import com.yxinsur.imc.business.vo.SupplierVo;
import com.yxinsur.imc.business.vo.select.SelectSupplier;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.business.domain.ImcSupplier;
import com.yxinsur.imc.business.service.IImcSupplierService;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 保险公司/供应商Controller
 * 
 * @author imc
 * @date 2021-03-23
 */
@Api(value="我的保险公司/供应商接口服务",tags={"5.2.我的供应商接口服务"})
@RestController
@RequestMapping("/business/supplier")
public class ImcSupplierController extends BaseController
{
    @Autowired
    private IImcSupplierService imcSupplierService;

    /**
     * 查询保险公司/供应商列表
     */
    @ApiOperation("我的供应商/保险公司分页列表查询")
    @GetMapping("/list")
    public TableDataInfo list(SupplierListForm supplierForm)
    {
        startPage();
        List<SupplierVo> list = imcSupplierService.selectImcSupplierList(supplierForm);
        return getDataTable(list);
    }

    /**
     * 导出保险公司/供应商列表
     */
    @ApiOperation("我的供应商/保险公司导出数据查询")
    @Log(title = "我的保险公司/供应商", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SupplierListForm supplierForm)
    {
        List<SupplierVo> list = imcSupplierService.selectImcSupplierList(supplierForm);
        ExcelUtil<SupplierVo> util = new ExcelUtil<SupplierVo>(SupplierVo.class);
        return util.exportExcel(list, "我的供应商列表数据");
    }

    /**
     * 新增保险公司/供应商
     */
    @ApiOperation("我的供应商/保险公司新增")
    @Log(title = "我的保险公司/供应商", businessType = BusinessType.INSERT)
    @PostMapping("/{repoSupplierIds}")
    public AjaxResult add(@PathVariable Long[] repoSupplierIds)
    {
        return toAjax(imcSupplierService.insertImcSupplier(repoSupplierIds));
    }
    /**
     * 删除保险公司/供应商
     */
    @ApiOperation("我的供应商/保险公司移除")
    @Log(title = "我的保险公司/供应商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imcSupplierService.deleteImcSupplierByIds(ids));
    }

    /**
     * 获取保险公司下拉列表
     */
    @ApiOperation("保险公司下拉列表数据查询")
	@PostMapping("/select/data")
    public List<SelectSupplier> selectDataList()
    {
        return this.imcSupplierService.selectDataList();
    }
}
